<%@page import="data.GeoData"%>
<%@page import="models.GeoModel"%>
<%@page import="models.CountModel"%>
<%@page import="java.util.List"%>
<%@page import="models.CategoryModel"%>
<%@page import="data.CountData"%>
<%@page import="data.CategoryData"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	String recentCategory = "";
	if(request.getAttribute("recentCategory")!=null&&!request.getAttribute("recentCategory").equals("")){
		recentCategory = (String)request.getAttribute("recentCategory"); 
	}	
	CategoryData cateData = new CategoryData();
	CountData countData = new CountData(); 
	String city = "";	
	if(request.getAttribute("city")!=null&&!request.getAttribute("city").equals("")){
		city = (String)request.getAttribute("city"); 
	}else{
		Cookie cookies [] = request.getCookies();	
		if (cookies != null)
		{
			for (int i = 0; i < cookies.length; i++) 
			{
				if (cookies [i].getName().equals ("city"))
				{
					city = cookies[i].getValue();
					break;
				}
			}
		}
	}
	GeoData geoData = new GeoData(); 
	GeoModel cityModel = geoData.getGeoByAlias(city);
	if(cityModel==null){
		cityModel = geoData.getGeoByAlias("ha-noi");
	}
%>
<div id="choiceType">	
	<ul class="clearafter">
		<li class="first <%=(recentCategory.equals("all")) ? "active" : ""%>">
			<a href="/<%=city%>"><strong>Tất cả</strong>
				<span>(<%=countData.getCountByCity(cityModel.getGeoId())%>)</span>
			</a>
		</li>
		<%
			int count = 1;
			List<CategoryModel> listCate = cateData.list();
			for (CategoryModel cate : listCate) {
				count += 1;
				CountModel countModel = countData.getCount(
						cate.getCategoryId(), cityModel.getGeoId());
		%>
		<li
			class="<%=(recentCategory.equals(cate.getCategoryId())) ? "active"
						: ""%>"><a
			href="/<%=city%>/<%=cate.getAlias()%>"><%=cate.getName()%><span>&nbsp;(<%=countModel != null ? countModel.getCount() : "0"%>)
			</span></a></li>
		<%
			}
		%>
	</ul>
</div>